<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>绘制矩形</title>
</head>
<style>
*{
    margin:0;
    padding:0
}
</style>
<body>
    <canvas id="canvas" width="500" height="500"></canvas>
    <script>
        var dom=document.getElementById('canvas'),
        ctx=dom.getContext('2d');
        ctx.fillStyle="303030";
        ctx.fillRect(20,0,200,200)
    </script>
</body>
</html>